package com.hnkywl.sts.dao.djgl;

import com.hnkywl.sts.entity.djgl.Goodses;
import net.ruixin.orm.hibernate.Page;
import net.ruixin.orm.hibernate.SimpleHibernateTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by VanHeiSing on 2015/12/15.
 */
@Repository
public class GoodsesDao extends SimpleHibernateTemplate<Goodses, Long> {

    public Page findGoodsesList(Long jydd_id, int pageNo, int pageSize) {
        String sql;
        Page<Goodses> page = new Page<Goodses>(pageNo, pageSize, 0);
        sql = "select count(*) from Goodses where jydd_id=?";
        Long c = null;
        c = (Long) findUnique(sql, jydd_id.toString());
        page.setTotalCount(c.intValue());
        //==============查询结果===============
        sql = " from Goodses where jydd_id=?";
        return find(page, sql, jydd_id.toString());
    }

    public Goodses findGoodses(Long jyddId, String bindNo) {
        String hql = " from Goodses where jydd_id=? and resource_serial_number_1 = ?";
        List<Goodses> list = find(hql, jyddId, bindNo);
        if (null != list && list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
}
